﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using _4T.Data;
using CMS.Core.Libs;
using _4T.Data.IDataContext;

namespace _4T.DAL
{
    public class PaymentProfileDAL
    {
        public int appStageLinkPaymentProfileDAL(string ProfileID, string VideoUrl, string ImageUrl, string Comment, DateTime editedTime)
        {
            int result = 0;
            ConnectionStringSettings ConnectionStringSettings =
              ConfigurationManager.ConnectionStrings["cnnString4T"];
            if (ConnectionStringSettings != null && !string.IsNullOrEmpty(ConnectionStringSettings.ConnectionString.Trim()))
            {
                string conString = ConnectionStringSettings.ConnectionString;

                SqlConnection conn = new SqlConnection(conString);
                SqlCommand cmd = new SqlCommand();
                try
                {
                    conn.Open();
                    cmd.CommandText = "sp_PaymentProfileAddStageLink";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@ProfileID", SqlDbType.NVarChar).Value = ProfileID;
                    cmd.Parameters.Add("@VideoUrl", SqlDbType.NVarChar).Value = VideoUrl;
                    cmd.Parameters.Add("@ImageUrl", SqlDbType.NVarChar).Value = ImageUrl;
                    cmd.Parameters.Add("@Comment", SqlDbType.NVarChar).Value = Comment;
                    cmd.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = editedTime;
                    cmd.Connection = conn;

                    result = cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    cmd.Dispose();
                    if (conn.State != ConnectionState.Closed)
                        conn.Close();
                }
            }
            return result;
        }
    }
}